<?php

namespace app\admin\validate\professionalqa;

use ShidianUtil\Thinkphp\Validate\BaseValidate;

/**
 * Class ProfessionalQa
 * @package app\professionalqa\validate
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037623
 */
class ProfessionalQa extends BaseValidate
{

    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id' => 'isId',
        'userId' => 'integer|egt:0|max:11',
        'question' => 'scalar|max:200',
        'categoryId' => 'integer|egt:0|max:11',
        'checkStatus' => 'integer|egt:0|max:1',
        'checkTime' => 'likeId',
        'isEnd' => 'integer|egt:0|max:1',
        'readNum' => 'integer|egt:0|max:11',
        'likeNum' => 'integer|egt:0|max:11',
        'answer' => 'scalar',
        'answer_time' => 'likeId',
        'answer_memberId' => 'integer|max:11',
        'answer_name' => 'scalar|max:64',
        'has_answer' => 'integer|max:1',
        'updated' => 'integer|egt:0|max:11',
        'created' => 'integer|egt:0|max:11',
        'page' => 'integer|egt:0|max:11',
        'page_size' => 'integer|egt:0|max:11',
    ];

    protected $field = [
        'id' => 'id',
        'userId' => 'userId',
        'question' => '问题',
        'categoryId' => '分类',
        'checkStatus' => 'checkStatus',
        'checkTime' => 'checkTime',
        'isEnd' => 'isEnd',
        'readNum' => 'readNum',
        'likeNum' => 'likeNum',
        'answer' => 'answer',
        'answer_time' => 'answer_time',
        'answer_memberId' => 'answer_memberId',
        'answer_name' => 'answer_name',
        'has_answer' => 'has_answer',
        'updated' => 'updated',
        'created' => 'created',
        'page' => '分页页数',
        'page_size' => '分页大小',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'id.require' => '缺少:attribute',
        'id.isId' => '请设置正确的:attribute',
        'userId.require' => '请输入:attribute',
        'userId.integer' => ':attribute应该是整数',
        'userId.egt' => ':attribute应该大于等于:rule',
        'userId.max' => ':attribute长度不能超过:rule位',
        'question.require' => '请输入:attribute',
        'question.scalar' => ':attribute应该是字符串',
        'question.max' => ':attribute长度不能超过:rule位',
        'categoryId.require' => '请输入:attribute',
        'categoryId.integer' => ':attribute应该是整数',
        'categoryId.egt' => ':attribute应该大于等于:rule',
        'categoryId.max' => ':attribute长度不能超过:rule位',
        'checkStatus.require' => '请输入:attribute',
        'checkStatus.integer' => ':attribute应该是整数',
        'checkStatus.egt' => ':attribute应该大于等于:rule',
        'checkStatus.max' => ':attribute长度不能超过:rule位',
        'checkTime.require' => '请选择:attribute',
        'checkTime.isId' => '请选择正确的:attribute',
        'isEnd.require' => '请输入:attribute',
        'isEnd.integer' => ':attribute应该是整数',
        'isEnd.egt' => ':attribute应该大于等于:rule',
        'isEnd.max' => ':attribute长度不能超过:rule位',
        'readNum.require' => '请输入:attribute',
        'readNum.integer' => ':attribute应该是整数',
        'readNum.egt' => ':attribute应该大于等于:rule',
        'readNum.max' => ':attribute长度不能超过:rule位',
        'likeNum.require' => '请输入:attribute',
        'likeNum.integer' => ':attribute应该是整数',
        'likeNum.egt' => ':attribute应该大于等于:rule',
        'likeNum.max' => ':attribute长度不能超过:rule位',
        'answer.require' => '请输入:attribute',
        'answer.scalar' => ':attribute应该是字符串',
        'answer_time.require' => '请选择:attribute',
        'answer_time.isId' => '请选择正确的:attribute',
        'answer_memberId.require' => '请输入:attribute',
        'answer_memberId.integer' => ':attribute应该是整数',
        'answer_memberId.max' => ':attribute长度不能超过:rule位',
        'answer_name.require' => '请输入:attribute',
        'answer_name.scalar' => ':attribute应该是字符串',
        'answer_name.max' => ':attribute长度不能超过:rule位',
        'has_answer.require' => '请输入:attribute',
        'has_answer.integer' => ':attribute应该是整数',
        'has_answer.max' => ':attribute长度不能超过:rule位',
        'updated.require' => '请输入:attribute',
        'updated.integer' => ':attribute应该是整数',
        'updated.egt' => ':attribute应该大于等于:rule',
        'updated.max' => ':attribute长度不能超过:rule位',
        'created.require' => '请输入:attribute',
        'created.integer' => ':attribute应该是整数',
        'created.egt' => ':attribute应该大于等于:rule',
        'created.max' => ':attribute长度不能超过:rule位',
        'page.require' => '请输入:attribute',
        'page.integer' => ':attribute应该是整数',
        'page.egt' => ':attribute应该大于等于:rule',
        'page.max' => ':attribute长度不能超过:rule位',
        'page_size.require' => '请输入:attribute',
        'page_size.integer' => ':attribute应该是整数',
        'page_size.egt' => ':attribute应该大于等于:rule',
        'page_size.max' => ':attribute长度不能超过:rule位',
    ];

    protected $scene = [
        'delete' => ['id' => 'require'],
        'index' => ['page', 'page_size'],
        'read' => ['id' => 'require'],
        'save' => ['question' => 'require', 'categoryId' => 'require', 'checkStatus', 'checkTime', 'isEnd', 'readNum', 'likeNum', 'answer', 'answer_time', 'answer_memberId', 'answer_name', 'has_answer', 'updated', 'created'],
    ];

}
